waypt: Check waypoint creation_time. Should not be lt. zero. Add function 'waypt_disp...
authoroliskoli <oliskoli>
Sun, 7 Sep 2008 16:43:14 +0000 (16:43 +0000)
committeroliskoli <oliskoli>
Sun, 7 Sep 2008 16:43:14 +0000 (16:43 +0000)
waypt.c

diff --git a/waypt.c b/waypt.c
index 176e6090bb0adf98f4aec2c00155d95aa0d98a11..7ff60bf277e727df4e442298831dc3c866ce964b 100644 (file)
--- a/waypt.c
+++ b/waypt.c
@@ -108,6 +108,7 @@ waypt_add(waypoint *wpt)
        double lon_orig = wpt->longitude;
        
        ENQUEUE_TAIL(&waypt_head, &wpt->Q);
+
        waypt_ct++;
 
        if (wpt->latitude < -90) wpt->latitude += 180;
@@ -116,12 +117,18 @@ waypt_add(waypoint *wpt)
        else if (wpt->longitude > +180) wpt->longitude -= 360;
        
        if ((wpt->latitude < -90) || (wpt->latitude > 90.0))
-               fatal ("Invalid latitude %f in waypoint %s.\n",
+               fatal("%s: Invalid latitude %f in waypoint %s.\n",
+                       wpt->session->name,
                        lat_orig, wpt->shortname ? wpt->shortname : "");
        if ((wpt->longitude < -180) || (wpt->longitude > 180.0))
                fatal ("Invalid longitude %f in waypoint %s.\n",
                        lon_orig, wpt->shortname ? wpt->shortname : "");
-
+       if (wpt->creation_time < 0) {
+               warning("%s: Invalid timestamp in waypoint %s.\n",
+                       wpt->session->name,
+                       wpt->shortname ? wpt->shortname : "");
+               wpt->creation_time = 0;
+       }
        /*
         * Some input may not have one or more of these types so we
         * try to be sure that we have these fields even if just by
@@ -254,6 +261,28 @@ waypt_disp_all(waypt_cb cb)
        }
 }
 
+void
+waypt_disp_session(const session_t *se, waypt_cb cb)
+{
+       queue *elem, *tmp;
+       waypoint *waypointp;
+       int i = 0;
+
+       QUEUE_FOR_EACH(&waypt_head, elem, tmp) {
+               waypointp = (waypoint *) elem;
+               if (waypointp->session == se) {
+                       if (global_opts.verbose_status) {
+                               i++;
+                               waypt_status_disp(waypt_ct, i);
+                       }
+                       (*cb) (waypointp);
+               }
+       }
+       if (global_opts.verbose_status) {
+               fprintf(stdout, "\r\n");
+       }
+}
+
 void
 waypt_init_bounds(bounds *bounds)
 {